<%@page language="java" pageEncoding="UTF-8" contentType="text/html;charset=utf-8"%>
<%@include file="/includes/taglibs.jsp"%>
<%@page import="com.feib.soeasy.util.UserUtil"%>
<%@page import="com.feib.soeasy.model.Payment"%>

<c:choose>
	<c:when test="${null != actionBean.resultPayment}">
		<table id="paymentListTable">
				<tr>
					<td colspan="6">
						<table>				
							<tr class="firsttr">
								<td colspan="6" class="paymentHeader">
									<c:out value="${actionBean.resultPayment.paymentName}"/></td>
							</tr>
							<tr class="secondtr">
								<th>繳費帳號</th>
								<td><c:out value="${actionBean.resultPayment.virtualAccount}"/></td>
								<th>姓名</th>
								<td><c:out value="${actionBean.resultPayment.payerName}"/></td>
								<th>總金額</th>
								<td align="right"><fmt:formatNumber value="${actionBean.resultPayment.totalAmount}" pattern="##,###" /></td>
							</tr>
							<tr>
								<th colspan="6">繳費明細</th>
							</tr>
							<c:set var="old" value="${true}"/>
							<c:forEach items="${actionBean.resultPayment.paymentItems}" var="paymentItem" varStatus="rowstat1">
							<c:if test="${paymentItem.amount != 0 }">
								<c:if test="${old}"><tr></c:if>
									<th><c:out value="${paymentItem.itemName}"/></th>
									<td colspan="2" align="right"><fmt:formatNumber value="${paymentItem.amount}" pattern="##,###" /></td>
									<c:if test="${not old}"> </tr> </c:if>
								<c:set var="old" value="${not old }"/>
							</c:if>
							</c:forEach>
							<%//old == flase =>基數個，需要再補空白欄位與結束符號 %>
							<c:if test="${not old}"><th>&nbsp;</th><td colspan="2">&nbsp;</td></tr></c:if>
						</table>
					</td>
				</tr>
		</table>			
		<script type="text/javascript">
		<!--
		$(document).ready(function() {
			$("[id^='okPaymentBtn-']").click(function() {
				doWriteOffPaymentsAction(paymentPk);
			});
			
			$( "#paymentsItemDiv" ).dialog( "destroy" );
			$( "#paymentsItemDiv" ).dialog({  title:'帳單明細' ,width: 600, resizable: true, modal: true  });
		});
		//-->
		</script>
	</c:when>
	<c:otherwise>
			<table id="listTable">
				<tr>
					<th>
						查無資料
					</th>
				</tr>
			</table>
		<script type="text/javascript">
		<!--
		$(document).ready(function() {
			$( "#paymentsItemDiv" ).dialog( "destroy" );
			$( "#paymentsItemDiv" ).dialog({  title:'帳單明細' ,width: 600, resizable: false, modal: true  });
		});
		//-->
		</script>
	</c:otherwise>
</c:choose>